//
//  AddressTableViewCell.m
//  markmap
//
//  Created by 甘世清 on 2024/3/26.
//

#import "AddressTableViewCell.h"

@implementation AddressTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
- (void)SQ_Style:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    [self.contentView addSubview:self.nameLabel];
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(10);
        make.right.equalTo(self.contentView.mas_right).offset(-20);
        make.left.equalTo(self.contentView).offset(34);
    }];
    [self.contentView addSubview:self.footLabel];
    [self.footLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.nameLabel.mas_bottom).offset(4);
        make.right.equalTo(self.contentView.mas_right).offset(-20);
        make.left.equalTo(self.contentView).offset(34);
    }];
    UIImageView * image = [[UIImageView alloc]init];
    image.image = SQGetImage(@"datouzhen");
    image.contentMode = UIViewContentModeScaleAspectFit;
    [self.contentView addSubview:image];
    [image mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(20);
            make.centerY.equalTo(self.contentView);
            make.left.equalTo(self.contentView).offset(10);
    }];
    UIView * lineView = [[UIView alloc]init];
    lineView.backgroundColor = SQColor999999;
    [self.contentView addSubview:lineView];
    [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(1);
        make.left.equalTo(self.contentView).offset(16);
        make.bottom.equalTo(self.contentView);
        make.right.equalTo(self.contentView.mas_right).offset(-20);
    }];
    self.FS_cellBottomView = self.footLabel;
}
- (void)setModel:(CLPlacemark *)model{
    _model = model;
    NSString *city = model.locality;
    if ([city isNotEmpty]) {
        self.nameLabel.text = [NSString stringWithFormat:@"%@",model.name];
        self.footLabel.text = [NSString stringWithFormat:@"%@%@",model.country,model.locality];
    } else {
        self.nameLabel.text = [NSString stringWithFormat:@"%@",model.name];
        self.footLabel.text = [NSString stringWithFormat:@"%@%@",model.country,model.administrativeArea];
    }
    self.nameLabel.text = [self.nameLabel.text stringByReplacingOccurrencesOfString:@"null" withString:@""];
    self.footLabel.text = [self.footLabel.text stringByReplacingOccurrencesOfString:@"null" withString:@""];
}

- (UILabel *)footLabel{
    if (!_footLabel) {
        _footLabel = [[UILabel alloc]init];
        _footLabel.font = FONT_MEDIUM(12);
        _footLabel.textColor = UIColor.whiteColor;
        _footLabel.numberOfLines = 0;
    }
    return _footLabel;
}

- (UILabel *)nameLabel{
    if (!_nameLabel) {
        _nameLabel = [[UILabel alloc]init];
        _nameLabel.font = FONT_MEDIUM(14);
        _nameLabel.textColor = UIColor.whiteColor;
        _nameLabel.numberOfLines = 0;
    }
    return _nameLabel;
}
@end
